package com.ui.fragment;

import roboguice.inject.InjectView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

import com.core.sdk.core.BaseFragment;
import com.core.sdk.utils.ImageUtil;
import com.ui.R;
import com.ui.activity.DatePickerActivity;
import com.ui.activity.ExpandListViewActivity;
import com.ui.activity.HorListViewActivity;
import com.ui.activity.LeftSliderMenuActivity;
import com.ui.activity.TestActionBarSherlockActivity;

public class MainFragment2 extends BaseFragment implements OnClickListener{

	@InjectView(R.id.fg_main2_btn)
	Button btnLeftSilderLayout;
	
	@InjectView(R.id.fg_main2_btn_hor)
	Button btnHorListView;
	
	@InjectView(R.id.fg_main2_btn_date_picker)
	Button btnDatePicker;
	
	@InjectView(R.id.fg_main2_iv_test)
	ImageView ivTest;
	
	@InjectView(R.id.fg_main2_btn_expand_list_view)
	Button btnExpandListView;
	
	@InjectView(R.id.fg_main2_btn_test_crash)
	Button btnCrash;
	
	@InjectView(R.id.fg_main2_btn_test_actionbar)
	Button btnActionbarSherlock;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	protected int getContentView() {
		return R.layout.fg_main2;
	}

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		btnLeftSilderLayout.setOnClickListener(this);
		btnHorListView.setOnClickListener(this);
		btnDatePicker.setOnClickListener(this);
		btnExpandListView.setOnClickListener(this);
		btnCrash.setOnClickListener(this);
		btnActionbarSherlock.setOnClickListener(this);
	}
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		ImageUtil.setAutoLayoutParams(ivTest,10);
	}

	@Override
	public void onClick(View v) {
		if(v == btnLeftSilderLayout){
			Intent it = new Intent(getBaesActivity(),LeftSliderMenuActivity.class);
			startActivity(it);
		}else if(v == btnHorListView){
			Intent it = new Intent(getBaesActivity(),HorListViewActivity.class);
			startActivity(it);
		}else if(v == btnDatePicker){
			Intent it = new Intent(getBaesActivity(),DatePickerActivity.class);
			startActivity(it);
		}else if(v == btnExpandListView){
			Intent it = new Intent(getBaesActivity(),ExpandListViewActivity.class);
			startActivity(it);
		}else if(v == btnCrash){
			throw new NullPointerException("Test Crash Exception");
		}else if(v == btnActionbarSherlock){
			Intent it = new Intent(getBaesActivity(),TestActionBarSherlockActivity.class);
			startActivity(it);
		}
		
	}
}
